//
//  HMComposeButton.swift
//  Weibo
//
//  Created by 黄亦寒 on 2016/9/30.
//  Copyright © 2016年 HM. All rights reserved.
//

import UIKit
//自定义十字菜单按钮
class HMComposeButton: UIButton {

    override init(frame: CGRect) {
        super.init(frame: frame)
        setUpUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    //使用pop动画需要重写isHighLighted方法
    override var isHighlighted: Bool {
        get {
            return false
        }set {
            
        }
    }
    
    private func setUpUI() {
        titleLabel?.textAlignment = .center
        titleLabel?.font = UIFont.systemFont(ofSize: 14)
        self.setTitleColor(UIColor.gray, for: .normal)
        imageView?.contentMode = .center
    }
    
    //布局子控件
    override func layoutSubviews() {
        super.layoutSubviews()
        //图片的大小
        imageView?.width = width
        imageView?.height = width
        imageView?.y = 0
        //label的大小
        titleLabel?.width = width
        titleLabel?.height = height - width
        //设置label的y为imageView的高度
        titleLabel?.y = width
        titleLabel?.x = 0
        
    }
}
